﻿<%@ Page Language="C#" MasterPageFile="~/reportpage.Master" AutoEventWireup="true" CodeBehind="BaoCao_THB.aspx.cs"
    Inherits="Baocao.BaoCao_THB" %>

<asp:Content ID="cthoadon" ContentPlaceHolderID="body" runat="server">

    <script type="text/javascript">
    $(document).ready(function () {
        $("#<%=dttuNgay.ClientID %>").dynDateTime({
            showsTime: true,
            ifFormat: "%d/%m/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
            button: ".next()"
        });
         $("#<%=dtdenNgay.ClientID %>").dynDateTime({
            showsTime: true,
            ifFormat: "%d/%m/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
            button: ".next()"
        });
        $("#<%=drnhomhang.ClientID %>").change(function() {
            $("#<%=txtMaHangHoa.ClientID %>").val("");
            $("#<%=txtTenHangHoa.ClientID %>").val("");
            });
        
        SearchHangHoa(); 
        SearchKhHang(); 
        SearchNhanVien();                   
    });    
       		
	    function SearchHangHoa() {
	        $("#<%=txtMaHangHoa.ClientID %>").autocomplete({
	            source: function(request, response) {
	                $.ajax({
	                    type: "POST",
	                    contentType: "application/json; charset=utf-8",
	                    url: "Search.aspx/GetAutoCompleteDataValue",
	                    data: "{'prefix':'"+request.term +"','suffix':'"+$("#<%= drnhomhang.ClientID %>").val()+"'}",
	                    dataType: "json",
	                    success: function(data) {
	                        response($.map(data.d, function (item) {
                            return {                                                              
                                value: item.split('-')[0],
                                lable: item.split('-')[1]
                                }
                            }))
	                    },
	                    error: function(result) {
	                        alert("Error");
	                    }
	                });
	            },
	            focus: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox
					$(this).val(ui.item.value);
				},
				select: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox and hidden field
					$(this).val(ui.item.value);
					$("#<%=txtTenHangHoa.ClientID %>").val(ui.item.lable);					
				}
	        });
	        
	        $("#<%=txtTenHangHoa.ClientID %>").autocomplete({
	            source: function(request, response) {
	                $.ajax({
	                    type: "POST",
	                    contentType: "application/json; charset=utf-8",
	                    url: "Search.aspx/GetAutoCompleteDataName",
	                    data: "{'prefix':'"+request.term +"','suffix':'"+$("#<%= drnhomhang.ClientID %>").val()+"'}",
	                    dataType: "json",
	                    success: function(data) {
	                        response($.map(data.d, function (item) {
                            return {                                                              
                                value: item.split('-')[0],
                                lable: item.split('-')[1]
                                }
                            }))
	                    },
	                    error: function(result) {
	                        alert("Error");
	                    }
	                });
	            },
	            focus: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox
					$(this).val(ui.item.value);
				},
				select: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox and hidden field
					$(this).val(ui.item.value);						
					$("#<%=txtMaHangHoa.ClientID %>").val(ui.item.lable);					
				}
	        });
	        	        	         	  
	    }    
	    
	    function SearchKhHang() {
	        $("#<%=txtMaKhHang.ClientID %>").autocomplete({
	            source: function(request, response) {
	                $.ajax({
	                    type: "POST",
	                    contentType: "application/json; charset=utf-8",
	                    url: "SearchKhHang.aspx/GetAutoCompleteDataValue",
	                    data: "{'prefix':'"+request.term +"'}",
	                    dataType: "json",
	                    success: function(data) {
	                        response($.map(data.d, function (item) {
                            return {                                                              
                                value: item.split('-')[0],
                                lable: item.split('-')[1]
                                }
                            }))
	                    },
	                    error: function(result) {
	                        alert("Error");
	                    }
	                });
	            },
	            focus: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox
					$(this).val(ui.item.value);
				},
				select: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox and hidden field
					$(this).val(ui.item.value);
					$("#<%=txtTenKhHang.ClientID %>").val(ui.item.lable);					
				}
	        });
	        
	        $("#<%=txtTenKhHang.ClientID %>").autocomplete({
	            source: function(request, response) {
	                $.ajax({
	                    type: "POST",
	                    contentType: "application/json; charset=utf-8",
	                    url: "SearchKhHang.aspx/GetAutoCompleteDataName",
	                    data: "{'prefix':'"+request.term +"'}",
	                    dataType: "json",
	                    success: function(data) {
	                        response($.map(data.d, function (item) {
                            return {                                                              
                                value: item.split('-')[0],
                                lable: item.split('-')[1]
                                }
                            }))
	                    },
	                    error: function(result) {
	                        alert("Error");
	                    }
	                });
	            },
	            focus: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox
					$(this).val(ui.item.value);
				},
				select: function(event, ui) {
					// prevent autocomplete from updating the textbox
					event.preventDefault();
					// manually update the textbox and hidden field
					$(this).val(ui.item.value);						
					$("#<%=txtMaKhHang.ClientID %>").val(ui.item.lable);					
				}
	        });
	        	        	         	  
	    }    
	    	    
       
    </script>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Table ID="Table1" runat="server" Width="848px" Height="69px" Style="text-align: left">
        <asp:TableRow>
            <asp:TableCell Width="30%">Từ ngày</asp:TableCell>
            <asp:TableCell Width="30%">
                <asp:TextBox ID="dttuNgay" runat="server" Width="150px"></asp:TextBox>
                <img src="Images/calender.png" /></asp:TableCell>
            <asp:TableCell Width="40%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Đến ngày</asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="dtdenNgay" runat="server" Width="150px"></asp:TextBox>
                <img src="Images/calender.png" /></asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Mã khách hàng</asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtMaKhHang" runat="server" Width="150px" Text="">
                </asp:TextBox>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Tên khách hàng</asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtTenKhHang" runat="server" Width="150px" Text="">
                </asp:TextBox>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Mã nhân viên</asp:TableCell>
            <asp:TableCell>
                <asp:DropDownList ID="drtennv" runat="server" Width="150px" AutoPostBack="true" OnSelectedIndexChanged="drtennv_SelectedIndexChange">
                </asp:DropDownList>
            </asp:TableCell>
            <asp:TableCell>
                <asp:UpdatePanel ID="Updatepanel1" runat="server">
                    <ContentTemplate>
                        <asp:Label ID="txtlbTenNv" runat="server" Width="150px" Text="">
                        </asp:Label>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="drtennv" EventName="SelectedIndexChanged" />
                    </Triggers>
                    </asp:UpdatePanel>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Nhóm hàng</asp:TableCell>
            <asp:TableCell>
                <asp:DropDownList ID="drnhomhang" runat="server" Width="150px">
                </asp:DropDownList>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Mã hàng hóa</asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtMaHangHoa" runat="server" Width="150px" Text="">
                </asp:TextBox>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Tên hàng hóa</asp:TableCell>
            <asp:TableCell>
                <asp:TextBox ID="txtTenHangHoa" runat="server" Width="150px" Text="">
                </asp:TextBox>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Nhóm vụ việc</asp:TableCell>
            <asp:TableCell>
                <asp:DropDownList ID="drnhomvuviec" runat="server" Width="150px" AutoPostBack="true"
                    OnSelectedIndexChanged="drnhomvuviec_SelectedIndexChange">
                </asp:DropDownList>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Vụ việc</asp:TableCell>
            <asp:TableCell>
                <asp:UpdatePanel ID="Updatepanel2" runat="server">
                    <ContentTemplate>
                        <asp:DropDownList ID="drvuviec" runat="server" Width="150px">
                        </asp:DropDownList>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="drnhomvuviec" EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>Chọn mẫu in</asp:TableCell>
            <asp:TableCell>
                <asp:DropDownList ID="drmauin" runat="server">
                    <asp:ListItem Value="R0073">Mẫu chỉ có số lượng</asp:ListItem>
                    <asp:ListItem Value="R0047">Mẫu in có số lượng và doanh thu</asp:ListItem>
                    <asp:ListItem Value="R0072">Mẫu in có số lượng, doanh thu và lãi/lỗ</asp:ListItem>
                    <asp:ListItem Value="R0106">Mẫu in doanh thu theo khách hàng</asp:ListItem>
                    <asp:ListItem Value="R0107">Mẫu in doanh thu theo nhân viên</asp:ListItem>
                    <asp:ListItem Value="R0108">Mẫu in doanh thu theo kho</asp:ListItem>
                    <asp:ListItem Value="R0109">Mẫu in doanh thu theo nhóm hàng</asp:ListItem>
                    <asp:ListItem Value="R0124">Mẫu in có số lượng, doanh thu và lãi/lỗ theo ngày</asp:ListItem>
                </asp:DropDownList>
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell HorizontalAlign="Right">
            </asp:TableCell>
            <asp:TableCell HorizontalAlign="Left">
                &nbsp;
                <asp:Button ID="btIn" runat="server" Text="Xem báo cáo" Width="125px" CssClass="my_btn_ok"
                    OnClick="btIn_Click" />
            </asp:TableCell>
            <asp:TableCell Width="30%"></asp:TableCell>
        </asp:TableRow>
    </asp:Table>
</asp:Content>
